<!--
 * Description: FD Tab 组件
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Qiuxue.Wu
 * Date: 2020/06/10 15:53
-->

<template>
  <div v-loading.fullscreen.lock="isRequesting" class="fd-data-edit">
    <el-page-header :content="$t('rfq.rfqEdit')" @back="goBack" />
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane :label="$t('FdData.fdBaseInfo')" name="first">
        <RfqDataBaseView v-if="stateControl.first" :inputData="inputData" />
      </el-tab-pane>
      <el-tab-pane :label="$t('FdData.fdDetailInfo')" name="second">
        <FdAssignPane
          v-if="stateControl.second"
          :inputData="inputData"
          :shareDataList="shareDataList"
          @cancel="cancel"
          @update="update"
        />
      </el-tab-pane>
      <el-tab-pane :label="$t('FdData.fdProjectInfo')" name="third">
        <RfqProject v-if="stateControl.third" :inputData="inputData" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import FdAssignPane from './RfqAssignPane'
import RfqDataBaseView from '../../components/RfqDataBaseView'
import RfqProject from '../../components/RfqProject'
import { RfqDetailFloorInfo } from '@/api/rfq/rfq'

export default {
  name: 'RfqTabView',
  components: {
    RfqDataBaseView,
    FdAssignPane,
    RfqProject
  },
  props: {
    visible: {
      default: false,
      type: Boolean
    },
    inputData: {
      type: Object,
      default: () => null
    }
  },
  data() {
    return {
      // 正在查询
      isRequesting: false,
      activeName: 'second',
      stateControl: {
        first: false,
        second: true,
        third: false,
        fourth: false,
        five: false
      },
      shareDataList: []
    }
  },
  mounted() {
    this.pageDataInit()
  },
  methods: {
    goBack() {
      this.$emit('update:visible', false)
    },
    handleClick(tab, event) {
      this.stateControl[tab.name] = true
    },
    cancel() {
      this.$emit('cancel')
    },
    update() {
      this.pageDataInit()
    },
    async pageDataInit() {
      try {
        // this.isRequesting = true
        const res = await RfqDetailFloorInfo({
          rfqId: this.inputData.rfqId,
          version: this.inputData.version
        })
        this.shareDataList = res.data
      } catch (error) {
        console.log(error)
      }
      //  finally {
      //   this.isRequesting = false
      // }
    }
  }
}
</script>
